-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes yield proc scheduling. Turns sleeps into an opcode #1539
base: master
Are you sure you want to change the base?
Conversation
0bb5985
to
4f0b534
Compare
rand_seed(22475) | ||
for(var/i in 1 to 10000) | ||
world.log << "Rand-[i]:" | ||
TestSequence(MODE_RAND) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to up the test timeout because this overran 500ms
Apparently this is still unperformant for the issue in question |
- Remove `sleep` from DMStandard. - Two new opcodes Sleep and BackgroundSleep (which is just `sleep -1`, much faster than popping a `float` off for background sleeps). - Create new lightweight async proc state for sleeping. - Compiler/runtime adjustments to handle new opcodes.
750403d
to
86fb394
Compare
DMCompiler/DM/DMProc.cs
Outdated
public void SleepDelayPushed() => WriteOpcode(DreamProcOpcode.Sleep); | ||
|
||
public void Sleep(float delay) { | ||
if(delay == -1.0f) // yielding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be <= 0
Somethings still fucky, which is why the TGS tests are failing |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
66dddbc
to
38e1ff4
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
The behavior is now the same for either
spawn
orsleep
:delay < 0
: Proc will continue immediately if nothing is scheduled in the same tick. Otherwise, same asdelay == 0
.delay == 0
: Proc scheduled on end of same tick.delay > 0
: Proc scheduled aftern
ticks.This also fixes the ProcScheduler being able to still have queued procs when running multiple tests in serial.
Then, to fix perf issues I had to redo sleeping into an opcode:
sleep
from DMStandard.Sleep
andBackgroundSleep
(which is justsleep -1
, much faster than popping afloat
off for background sleeps).IOpenDreamGameTiming
as a wrapper aroundIGameTiming
that we can control in unit tests.Closes #1262